import { reqCategoryList, reqBanner, reqFloorList } from '@/api'
export default {
    state:{
        // 分类列表
        categoryList: [],
        bannerList: [],
        floorList: []
    },
    mutations:{
        categoryList(state, data){
            state.categoryList = data
        },
        bannerList(state, data){
            state.bannerList = data
        },
        floorList(state, data){
            state.floorList = data
        }
    },
    actions:{
        //通过api获取商品分类数据
        async categoryList({commit}){
            let res = await reqCategoryList()
            if (res.code === 200){
                commit('categoryList', res.data)
            }
        },
        // 轮播图数据
        async getBannerList({commit}){
            let res = await reqBanner()
            if (res.code === 200){
                commit('bannerList', res.data)
            }
        },
        // floor数据
        async getFloorList({commit}){
            let res = await reqFloorList()
            if (res.code === 200){
                commit('floorList', res.data)
            }
        }
    },
    getters:{}
}
